package Watcher;

import Watcher.impl.Favorite;
import Watcher.impl.VideoDummy;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Window extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3157767812826654275L;
	JTextField textfieldFavoriteLink;
	JTextField textfieldFavoriteName;
    JPanel panel = new JPanel();

	IVideo video = new VideoDummy();

	JButton button;

	public Window() {
		this.getContentPane().setLayout(null);
		this.initWindow();
		this.addWindowListener(new WindowListener() {
			public void windowClosed(WindowEvent arg0) {

			}

			public void windowActivated(WindowEvent e) {

			}

			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}

			public void windowDeactivated(WindowEvent e) {

			}

			public void windowDeiconified(WindowEvent e) {

			}

			public void windowIconified(WindowEvent e) {

			}

			public void windowOpened(WindowEvent e) {

			}
		});

	}

	protected void initWindow() {
		// Instanzieren:
		textfieldFavoriteLink = new JTextField();
		textfieldFavoriteName = new JTextField();

		this.setTitle("YouTubeWatcher");

		button = new JButton("Add new favorite");

		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				buttonSaveFavoriteClicked();
			}
		});

	    String subject[] = {"Math", "Computer", "Phisics", "Chemestry"};
	    panel.setBounds(5, 300, 200, 200);
	    
		
		// Positionen festlegen
		textfieldFavoriteLink.setBounds(182, 12, 400, 25);
		textfieldFavoriteName.setBounds(182, 55, 400, 25);

		button.setBounds(182, 103, 300, 30);
		
		// Elemente dem Fenster hinzuf�gen:
		this.getContentPane().add(textfieldFavoriteLink);
		this.getContentPane().add(textfieldFavoriteName);
		this.getContentPane().add(panel);
		this.getContentPane().add(button);
		{
			JList list = new JList(subject);
			getContentPane().add(list);
			list.setBounds(32, 153, 63, 68);
		}
		
		this.pack();
		this.setSize(644, 385);
	}

	public void buttonSaveFavoriteClicked() {
		String favoriteLink = textfieldFavoriteLink.getText();
		String favoriteName = textfieldFavoriteName.getText();

		Favorite favorite = new Favorite(favoriteLink, favoriteName);
	}
}
